<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

function PbnyBuildRoute(&$query)
{
  $segments = array();
  if (isset($query['controller'])){
    $segments[] = $query['controller'];
    unset($query['controller']);
  }
  
  if (isset($query['task'])){
    $segments[] = $query['task'];
    unset($query['task']);
  }
  
  if(isset($query['id'])){
    $segments[] = $query['id'];
    unset($query['id']);
  }
  
  return $segments;
}

function PbnyParseRoute($segments)
{
  $vars = array();
  
  $vars['controller'] = $segments[0];
  $vars['view'] = $segments[0];  #dynamic generation of links from menu manager, defaults "view" not controller
  
  $vars['task'] = 'display';
  $vars['id'] = '';
  $vars['others'] = '';
  $vars['others2'] = '';
  
  if(isset($segments[1]))
    $vars['task'] = $segments[1];
    
  if(isset($segments[2]))
    $vars['id'] = $segments[2];
    
  if(isset($segments[3]))
    $vars['others'] = $segments[3];
    
  if(isset($segments[4]))
    $vars['others2'] = $segments[4];
  
  return $vars;
}
?>
